<template>
	<view class="container">
		<uni-nav-bar class="ch-nav" height="88rpx" backgroundColor="#ffffff" leftWidth="90rpx" rightWidth="90rpx" color="#333" :fixed="true" :padding="false" :border="false" @clickLeft="$goBack(1)">
			<template slot="left">
				<image class="left" src="@/public/images/public/dhl_fhjt.png" mode="aspectFit"></image>
			</template>
			<text class="title">中奖记录</text>
		</uni-nav-bar>
		<view class="body bottom-ios">
			<EmptyContent v-if="!recordList[0]" top="250rpx" text="暂无中奖记录" img="qsy_zwyhq" @refresh="getLuckyRecords"></EmptyContent>
			<view class="record-list pb20" v-else>
				<view class="record flex-r ac jsb" v-for="(record, index) in recordList" :key="index">
					<view class="record-left flex-c">
						<text class="left-title">{{record.awardResult}}</text>
						<text class="left-info">{{record.useTime}}</text>
					</view>
					<image v-if="record.awardType == 1" class="record-icon" src="@/public/images/other/yhq.png" mode="aspectFit"></image>
					<image v-if="record.awardType == 2" class="record-icon" src="@/public/images/other/chd.png" mode="aspectFit"></image>
					<image v-if="record.awardType == 3" class="record-icon" src="@/public/images/other/czz.png" mode="aspectFit"></image>
				</view>
			</view>
			<view class="list-end flex-r pb20" v-if="isEnd && recordList[0]">
				<text>已经到底啦～</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				recordList: [],
				pageNo: 1,
				isEnd: false
			};
		},
		onLoad() {
			this.getLuckyRecords()
		},
		onReachBottom() {
			if(!this.isEnd){
				this.getLuckyRecords()
			}
		},
		methods: {
			getLuckyRecords() {
				this.$http.get({
					url: '/api/lucky/luckyDrawRecord',
					data: {
						pageNo: this.pageNo,
						pageSize: 10
					}
				}).then(data => {
					console.log(data);
					if(data.success && data.result && data.result.total){
						if(data.result.current == 1){
							this.recordList = data.result.records
						}else{
							this.recordList.push(...data.result.records)
						}
						this.isEnd = data.result.current >= data.result.pages
						this.pageNo = data.result.current + 1
					}
				}).catch((err) => {
					console.log(err);
				})
			}
		}
	}
</script>

<style lang="scss">
	.body{
		margin-top: 20rpx;
		.record-list{
			.record{
				background: #FFFFFF;
				padding: 30rpx 20rpx;
				.record-left{
					.left-title{
						font-size: 28rpx;
						font-weight: 500;
						line-height: 28rpx;
					}
					.left-info{
						margin-top: 20rpx;
						font-size: 24rpx;
						font-family: Arial;
						line-height: 24rpx;
						color: #999999;
					}
				}
				.record-icon{
					width: 64rpx;
					height: 64rpx;
				}
			}
			.record:not(:last-child){
				border-bottom:  1rpx solid #EDEDED;
			}
		}
	}
</style>
